package com.example.sxy_project;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import java.util.List;

class TongxunluAdapter extends ArrayAdapter<Tongxunlu> {
    private int resourceId;
    private static final String TAG = "TongxunluAdapter";
    private List<Tongxunlu> list;

    public TongxunluAdapter(@NonNull Context context, int resource, @NonNull List<Tongxunlu> objects) {
        super(context, resource, objects);
        resourceId = resource;
    }

    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent)
    {
        Tongxunlu tongxunlu = getItem(position);
        View view = LayoutInflater.from(getContext()).inflate(resourceId,
                parent, false);

        ImageView t_tx = view.findViewById(R.id.t_tx);
        TextView t_name = view.findViewById(R.id.t_name);

        t_tx.setImageResource(tongxunlu.getImageId());
        t_name.setText(tongxunlu.getName());

        return view;
    }
}